﻿using ConfExpert.Forms.Base;
using DevTeam;

using System;
using System.Drawing;

namespace ConfExpert.Forms.Araclar
{
    public partial class BarkodSay : XForm
    {
        public BarkodSay()
        {
            InitializeComponent();
        }

        private void BarkodSay_Load(object sender, EventArgs e)
        {
            
            gridView1.Init("GetBarkodSay");
            gridView1.FormatAsDate("Tarih");
            gridView1.AddSummary();
            gridView1.BestFitColumns();

            gridView1.DoubleClick += gridView1_DoubleClick;
            gridView1.OptionsView.EnableAppearanceEvenRow = false;
            gridView1.RowStyle += gridView1_RowStyle;

            btnYeni.ItemClick += btnYeni_ItemClick;
        }

        void btnYeni_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            Digits = intParse(txtDigits.EditValue);
            ParityBits = intParse(txtParity.EditValue);
            BarkodSayId = (int)ExecuteScalar("UpdBarkodSay", txtAciklama.EditValue.ToStr(), WhoAmI);
            if (BarkodSayId > 0)
                this.DialogResult = System.Windows.Forms.DialogResult.OK;
        }

        public int BarkodSayId = 0;
        public int Digits, ParityBits;
        void gridView1_DoubleClick(object sender, EventArgs e)
        {
            Digits = intParse(txtDigits.EditValue);
            ParityBits = intParse(txtParity.EditValue);
            BarkodSayId = intParse(gridView1.GetFocusedRowCellDisplayText("BarkodSayId"));
            if (BarkodSayId > 0)
                this.DialogResult = System.Windows.Forms.DialogResult.OK;
        }

        void gridView1_RowStyle(object sender, DevExpress.XtraGrid.Views.Grid.RowStyleEventArgs e)
        {
            if (e.RowHandle == gridView1.FocusedRowHandle)
                e.Appearance.BackColor = Color.YellowGreen;

        }
    }
}
